<template>
	<view>
		<view  class="order-item"  >
			<view class="i-top b-b">
				<text class="time">订单号:{{orderinfo.orderno}}</text>
				<text class="state" :style="{color: orderinfo.stateTipColor}">{{orderinfo.stateTip}}</text>
 
			</view>
		 
			<view class="goods-box-single">
				<image class="goods-img" :src="orderinfo.productinfo.product_image" mode="aspectFill"></image>
				<view class="right">
					<text class="title clamp">{{orderinfo.productinfo.product_title}}</text>
					<text class="attr-box">{{orderinfo.productinfo.specvalue_text}} </text>
					<text class="price">{{orderinfo.productinfo.total_productprice}}</text>
				</view>
			</view>
		
		</view>
		
		<view class="tipitem">
			<view class="tiptitle">申请原因</view>
			<text class="tipcontent">{{orderinfo.reason}}</text>
		</view>
		<view class="tipitem">
	    	<view class="tiptitle">提交图片</view>
			<view class="tipimage" v-if="imglist.length>0">
				<image mode="aspectFill" @click="preimage(index)" v-for="(item,index) in imglist" :key="index" :src="item"></image>
 			
			
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderinfo:{
					"productinfo":{}
				},
				id:0,
				imglist:[]
			}
		},
		onLoad(option) {
			this.id = option.id || 0;
			this.getinfo();
		},
		methods: {
			preimage(index){
				uni.previewImage({
					current:index,
					urls:this.imglist,
					  indicator: 'number',
					 loop: true
				});
			},
			getinfo(){
				let param={
					id:this.id
				}
				let that = this;
				this.$util.req("/orderservice/getInfo",param,true,function(res){
					
					let {stateTip,stateTipColor} = that.orderStateExp(res.data.status);
					res.data.stateTip = stateTip;
					res.data.stateTipColor = stateTipColor;
					that.orderinfo = res.data;
					
					that.imglist = res.data.remark_images.split(",");
					console.log(that.imglist);
				});
			},
			//订单状态文字和颜色
			orderStateExp(pay_status, trans_status, status) {
				let stateTip = '',
					stateTipColor = '#fa436a';
					//服务状态:0=待处理,1=处理中,2=已处理
				if (status == "2") {
					stateTip = "已处理";
					stateTipColor = '#909399';
				} else if(status=="0"){
					stateTip = "待处理";
				}else{
					stateTip = "处理中";
				}
			
			 
				return {
					stateTip,
					stateTipColor
				};
			}
		}
	}
</script>


<style lang="scss">
	page,
	.content {
		background: $page-color-base;
		height: 100%;
	}
	.tipitem{
		margin-top: 20upx;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
		padding: 20upx;
		color: $font-color-dark;
		font-size: $font-base;
		.tiptitle{ 
			font-size: 32upx;
			margin-bottom: 10upx;
		}
		.tipcontent{
		
			line-height: 42upx;
			display: flex;
		}
		.tipimage{
		 
			display: flex;
			flex-wrap: wrap;
			 width: 100%;
			image{
				border-radius: 40upx;
				padding: 10upx; 
			min-width: 50%;
			max-width: 50%;
				 flex:1;
				height: 300upx;
			
			}
		}
		
	}
	.order-item {
		display: flex;
		flex-direction: column;
		padding-left: 30upx;
		background: #fff;
		margin-top: 16upx;

		.i-top {
			display: flex;
			align-items: center;
			height: 80upx;
			padding-right: 30upx;
			font-size: $font-base;
			color: $font-color-dark;
			position: relative;

			.time {
				flex: 1;
			}

			.state {
				color: $base-color;
			}

			.del-btn {
				padding: 10upx 0 10upx 36upx;
				font-size: $font-lg;
				color: $font-color-light;
				position: relative;

				&:after {
					content: '';
					width: 0;
					height: 30upx;
					border-left: 1px solid $border-color-dark;
					position: absolute;
					left: 20upx;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}

		/* 多条商品 */
		.goods-box {
			height: 160upx;
			padding: 20upx 0;
			white-space: nowrap;

			.goods-item {
				width: 120upx;
				height: 120upx;
				display: inline-block;
				margin-right: 24upx;
			}

			.goods-img {
				display: block;
				width: 100%;
				height: 100%;
			}
		}

		/* 单条商品 */
		.goods-box-single {
			display: flex;
			padding: 20upx 0;

			.goods-img {
				display: block;
				width: 120upx;
				height: 120upx;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				padding: 0 30upx 0 24upx;
				overflow: hidden;

				.title {
					font-size: $font-base + 2upx;
					color: $font-color-dark;
					line-height: 1;
				}

				.attr-box {
					font-size: $font-sm + 2upx;
					color: $font-color-light;
					padding: 10upx 12upx;
				}

				.price {
					font-size: $font-base + 2upx;
					color: $font-color-dark;

					&:before {
						content: '￥';
						font-size: $font-sm;
						margin: 0 2upx 0 8upx;
					}
				}
			}
		}

		.price-box {
			display: flex;
			justify-content: flex-end;
			align-items: baseline;
			padding: 20upx 30upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;

			.num {
				margin: 0 8upx;
				color: $font-color-dark;
			}

			.price {
				font-size: $font-lg;
				color: $font-color-dark;

				&:before {
					content: '￥';
					font-size: $font-sm;
					margin: 0 2upx 0 8upx;
				}
			}
		}

		.action-box {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 100upx;
			position: relative;
			padding-right: 30upx;
		}

		.action-btn {
			width: 160upx;
			height: 60upx;
			margin: 0;
			margin-left: 24upx;
			padding: 0;
			text-align: center;
			line-height: 60upx;
			font-size: $font-sm + 2upx;
			color: $font-color-dark;
			background: #fff;
			border-radius: 100px;

			&:after {
				border-radius: 100px;
			}

			&.recom {
				background: #fff9f9;
				color: $base-color;

				&:after {
					border-color: #f7bcc8;
				}
			}
		}
	}

</style>
